/**
 * 身体数据服务
 */

import { BaseApiService } from '../utils/api';
import {
  UserBodyDataVo,
  UserBodyDataBo,
} from '../types/api';

export class BodyDataService extends BaseApiService {
  
  /**
   * 獲取身體數據
   */
  async getBodyData(): Promise<UserBodyDataVo> {
    return this.handleResponse(
      this.http.get<UserBodyDataVo>('/api/body-data')
    );
  }

  /**
   * 保存或更新身體數據
   */
  async saveOrUpdateBodyData(data: UserBodyDataBo): Promise<void> {
    return this.handleResponse(
      this.http.post<void>('/api/body-data', data)
    );
  }

  /**
   * 刪除身體數據
   */
  async deleteBodyData(): Promise<void> {
    return this.handleResponse(
      this.http.delete<void>('/api/body-data')
    );
  }

  /**
   * 獲取身體數據歷史記錄
   */
  async getBodyDataHistory(limit: number = 10): Promise<UserBodyDataVo[]> {
    return this.handleResponse(
      this.http.get<UserBodyDataVo[]>('/api/body-data/history', { limit })
    );
  }
}

// 導出單例實例
export const bodyDataService = new BodyDataService();
